#pragma once

#include "DataConfigs.h"
#include "AutoGen_DataBlock.h"

namespace data
{
	struct IRequestHandler;

	struct Slot
	{
		MemorySlotConfig				config;
		std::vector<unsigned char>		memory;
		std::vector<IRequestHandler*>	handlers;	
		struct DataBlock*				pOwner;
	};

	struct DataBlock
	{
		DataBlockConfig					config;
		Slot*							pSlot;
		cr::uint64_t					timeStamp;
	};

	typedef DataBlock* DataBlockHandle;
	static const DataBlockHandle cInvalidDataBlockHandle = 0;

	struct Request
	{
		enum EState
		{
			EState_Idle,
			EState_Register_CheckingForLoadedData,
			EState_Register_AquiringSlot,
			EState_Register_ReadingFile,
			EState_Register_StartProcessing,
			EState_Register_Processing,
			EState_Register_StartRegistering,
			EState_Register_Registering,
			EState_Release_StartUnregistering,
			EState_Release_Unregistering,
			EState_Release_StartUnprocessing,
			EState_Release_Unprocessing,
			EState_Release_FreeingSlot,
		};

		EState							state;
		IRequestHandler*				pHandler;
		DataBlockHandle					hDataBlockHandle;
		pf::FileIO::FileHandle			hFile;
		bool							isReload;
	};
}